export const InfoSchema = {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://example.com/form-groups-schema.json",
  "title": "Form Groups Configuration Schema",
  "description": "分组表单配置定义",
  "type": "object",
  "properties": {
    "groups": {
      "type": "array",
      "description": "表单分组配置",
      "items": {
        "type": "object",
        "description": "表单分组",
        "properties": {
          "groupName": {
            "type": "string",
            "description": "分组名称",
            "minLength": 1,
            "examples": ["权限基本信息", "基本要素信息"]
          },
          "data": {
            "type": "array",
            "description": "表单项配置，支持一维数组（单行）或二维数组（多行布局）",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/definitions/formItem"
                },
                {
                  "type": "array",
                  "description": "表单项行，每行包含多个表单项",
                  "items": {
                    "$ref": "#/definitions/formItem"
                  },
                  "minItems": 1
                }
              ]
            },
            "minItems": 1
          },
          "collapsible": {
            "type": "boolean",
            "description": "是否可折叠",
            "default": false
          },
          "defaultCollapsed": {
            "type": "boolean",
            "description": "默认是否折叠",
            "default": false
          }
        },
        "required": ["groupName", "data"],
        "additionalProperties": false
      },
      "minItems": 1
    }
  },
  "required": ["groups"],
  "additionalProperties": false,
  "definitions": {
    "formItem": {
      "type": "object",
      "description": "表单项配置",
      "properties": {
        "type": {
          "type": "string",
          "description": "表单项类型",
          "enum": ["text", "number", "textarea", "select", "radio", "checkbox", "date", "datetime", "switch", "slider"],
          "default": "text",
          "examples": ["text", "number", "radio"]
        },
        "label": {
          "type": "string",
          "description": "表单项标签",
          "minLength": 1
        },
        "property": {
          "type": "string",
          "description": "对应的数据字段名",
          "minLength": 1,
          "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
        },
        "required": {
          "type": "boolean",
          "description": "是否必填",
          "default": false
        },
        "disabled": {
          "type": "boolean",
          "description": "是否禁用",
          "default": false
        },
        "placeholder": {
          "type": "string",
          "description": "占位符文本"
        },
        "codeFrom": {
          "type": "object",
          "description": "数据来源配置",
          "properties": {
            "from": {
              "type": "string",
              "description": "数据来源标识",
              "minLength": 1,
              "examples": ["Status", "MenuType", "Visible"]
            },
            "codeIn": {
              "type": "array",
              "description": "包含的代码值",
              "items": {
                "type": "string"
              },
              "default": []
            },
            "codeNotIn": {
              "type": "array",
              "description": "排除的代码值",
              "items": {
                "type": "string"
              },
              "default": []
            }
          },
          "required": ["from"],
          "additionalProperties": false
        },
        "defaultValue": {
          "description": "默认值",
          "oneOf": [
            { "type": "string" },
            { "type": "number" },
            { "type": "boolean" },
            { "type": "array" },
            { "type": "object" }
          ]
        },
        "rules": {
          "type": "array",
          "description": "验证规则",
          "items": {
            "type": "object",
            "properties": {
              "required": { "type": "boolean" },
              "message": { "type": "string" },
              "trigger": {
                "type": "string",
                "enum": ["blur", "change"],
                "default": "blur"
              },
              "pattern": { "type": "string" },
              "min": { "type": "number" },
              "max": { "type": "number" },
              "validator": { "type": "string" }
            }
          }
        },
        "span": {
          "type": "integer",
          "description": "栅格占据的列数",
          "minimum": 1,
          "maximum": 24,
          "default": 24
        },
        "help": {
          "type": "string",
          "description": "帮助文本"
        },
        "tooltip": {
          "type": "string",
          "description": "提示文本"
        }
      },
      "required": ["type", "label", "property"],
      "additionalProperties": false
    }
  }
}